package _13_red_black_tree.case3;

import org.junit.Test;

import java.util.*;

/**
 * @author: mornd
 * @dateTime: 2023/6/16 - 17:26
 */
public class MyTest {
    @Test
    public void test() {
        RedBlackTree rbTree = new RedBlackTree();
        for (int i = 1; i <= 20; i++) {
            rbTree.put(i, null);
            System.out.println(rbTree);
        }
    }

    @Test
    public void testRemove() {
        for (int i = 20; i > 0; i--) {
            RedBlackTree rbTree = genericTree();
            rbTree.remove(i);
            System.out.println("key=" + i);
            System.out.println(rbTree);
            System.out.println("\n\n------------------------------------\n\n");
        }
    }

    @Test
    public void testRemove2() {
        RedBlackTree rbTree = genericTree();
        for (int i = 20; i > 0; i--) {
            rbTree.remove(i);
            System.out.println("key=" + i);
            System.out.println(rbTree);
            System.out.println("\n\n------------------------------------\n\n");
        }
    }

    private RedBlackTree genericTree() {
        RedBlackTree rbTree = new RedBlackTree();
        for (int i = 1; i <= 20; i++) {
            rbTree.put(i, null);
        }
        return rbTree;
    }

}
